<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>执行运算符</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="language.operators.errorcontrol.html">« 错误控制运算符</a></li>
      <li style="float: right;"><a href="language.operators.increment.html">递增／递减运算符 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="language.operators.html">运算符</a></li>
    <li>执行运算符</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="language.operators.execution" class="sect1">
   <h2 class="title">执行运算符</h2>
   <p class="para">
    PHP 支持一个执行运算符：反引号（``）。注意这不是单引号！PHP
    将尝试将反引号中的内容作为 shell 命令来执行，并将其输出信息返回（即，可以赋给一个变量而不是简单地丢弃到标准输出）。使用反引号运算符“`”的效果与函数
    <span class="function"><a href="function.shell-exec.html" class="function">shell_exec()</a></span> 相同。
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$output&nbsp;</span><span style="color: #007700">=&nbsp;`</span><span style="color: #DD0000">ls&nbsp;-al</span><span style="color: #007700">`;<br />echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;</span><span style="color: #0000BB">$output</span><span style="color: #DD0000">&lt;/pre&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     关闭了 <span class="function"><a href="function.shell-exec.html" class="function">shell_exec()</a></span> 时反引号运算符是无效的。
    </p>
   </p></blockquote>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     与其它某些语言不同，反引号不能在双引号字符串中使用。
    </p>
   </p></blockquote>

   <div class="sect2">
    <h3 class="title">参见</h3>
    <p class="para">
     <ul class="simplelist">
      <li class="member"><a href="ref.exec.html" class="link">程序执行函数</a></li>
      <li class="member"><span class="function"><a href="function.popen.html" class="function">popen()</a></span></li>
      <li class="member"><span class="function"><a href="function.proc-open.html" class="function">proc_open()</a></span></li>
      <li class="member"><a href="features.commandline.html" class="link">PHP 的命令行模式</a></li>
     </ul>
    </p>
   </div>
  </div></div></div></body></html>